$( document ).ready(function() {
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));
    var score = $("#userScore").val();
    var seriesData=[];
    var dataValue = JSON.parse(score);
    var total = 0;
    $("#id-score-list").html("");
    var score_html = "";
    for(var i= 0; i<dataValue.length;i++){
    	var obj = new Object();
    	total+=parseInt(dataValue[i].value);
    	obj.value=dataValue[i].value;
    	obj.name=dataValue[i].name;
    	seriesData.push(obj);
        score_html = score_html + "<li><i class=\"icon01\"></i>"+obj.name+obj.value+"分</li>";
    }

    $("#id-score-list").html(score_html);
    $(".two>b").html(total);
    myChart.title = '环形图';
    var option = {
        tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b}: {c} ({d}%)"
        },
        legend: {
            orient: 'vertical',
            x: 'left'
        },
        series: [
            {
                name:'信用得分',
                type:'pie',
                radius: ['50%', '70%'],
                avoidLabelOverlap: false,
                label: {
                    normal: {
                        show: false,
                        position: 'center'
                    },
                    emphasis: {
                        show: true,
                        textStyle: {
                            fontSize: '30',
                            fontWeight: 'bold'
                        }
                    }
                },
                labelLine: {
                    normal: {
                        show: false
                    }
                },
                data:seriesData
                
            }
        ]
    };

    //option.series[0].data=score;
    //console.log(JSON.stringify(option));
    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
});
